﻿using System;
using System.Collections;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Xml;
using System.IO;
using DigiLib;

public partial class Administrator_Controls_Logo : Admin_Controls_Base
{
    private string logo = string.Empty;
    private string banner = string.Empty;
    protected void Page_Load(object sender, EventArgs e)
    {
        base.removeHGC(divMessage);
        if (!IsPostBack)
            loadData();
    }
    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        try
        {
            if (fupLogo.HasFile)
            {
                fupLogo.SaveAs(Server.MapPath("~/images/logo.png"));
            }
            if (fupBanner.HasFile)
            {
                fupBanner.SaveAs(Server.MapPath("~/images/banner_slogan.png"));
            }
            string fname = Server.MapPath(Setting.PathBanner);
            XmlTextWriter xw = new XmlTextWriter(fname, null);
            xw.Formatting = Formatting.Indented;
            xw.Indentation = 6;
            xw.WriteStartDocument();
            xw.WriteStartElement("Banner");
            //xw.WriteStartElement("Logo");
            //xw.WriteString(logo);
            //xw.WriteEndElement();
            //xw.WriteStartElement("Banner");
            //xw.WriteString(banner);
            //xw.WriteEndElement();
            xw.WriteStartElement("Link");
            xw.WriteString(txtLink.Text.Trim());
            xw.WriteEndElement();
            xw.WriteEndElement();
            xw.WriteEndDocument();
            xw.Flush();
            xw.Close();
            divMessage.InnerHtml = MessageBox.Success("Thông Báo", "Cập nhật thành công.");
            loadData();
        }
        catch (Exception)
        {
            throw;
        }
    }
    private void loadData()
    {
        ctLogo.Src = "/images/logo.png";
        ctBanner.Src = "/images/banner_slogan.png";
    }
}
